<?php

class Admin_Form_AddAclResource extends Custom_Form
{
	private $_resource_id = '';

	function  __construct($resource_id = '') {
		$this->_resource_id = $resource_id;
		parent::__construct(null);
	}

    public function init()
    {
		$translate = Zend_Registry::get('translate');
		$this->setTranslator($translate);
	    $this->setName("acl_resource");
        $this->setMethod('post');

		$this->addElement('text', 'resource', array(
            'filters'    => array('StringTrim','StringToLower'),
            'validators' => array(
                array('StringLength', false, array(0, 50)),
				array('Db_NoRecordExists',false,array('table'=>'vt_acl_resources','field'=>'resource','exclude'=>array('field'=>'id','value'=>$this->_resource_id)))
			),

            'required'   => true,
            'label'      => __('Resource').':',
        ));

		$this->addElement('text', 'description', array(
            'filters'    => array('StringTrim'),
            'validators' => array(
                array('StringLength', false, array(0, 255)),
			),
            'required'   => true,
            'label'      => __('Description').':',
        ));


		$this->addElement('submit', 'save', array(
            'required' => false,
            'ignore'   => true,
            'label'    => __('Save'),
        ));

		$this->save->removeDecorator('label');
		//add validation message
		$this->resource->addErrorMessage('ERR_INVALID_ACL_RESOURCE');
		$this->description->addErrorMessage('ERR_INVALID_ACL_RESOURCE_DESC');
	}

}

